package com.zhl.media.login.mvp.model;

import android.app.Application;

import com.google.gson.Gson;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.zhl.media.commonsdk.entity.Token;
import com.zhl.media.commonsdk.entity.User;
import com.zhl.media.login.mvp.contract.LoginContract;
import com.zhl.media.login.mvp.model.api.service.LoginService;

import javax.inject.Inject;

import io.reactivex.Observable;


@ActivityScope
public class LoginModel extends BaseModel implements LoginContract.Model {
    @Inject
    Gson mGson;
    @Inject
    Application mApplication;

    @Inject
    public LoginModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<Token> getToken(String user, String pass) {
        return mRepositoryManager.obtainRetrofitService(LoginService.class).getToken(user,pass,"password");
    }

    @Override
    public Observable<Object> getUserInfo() {
        return mRepositoryManager.obtainRetrofitService(LoginService.class).getUserInfo();
    }
}
